home *** CD-ROM | disk | FTP | other *** search
/ Winzipper / Winzipper_ISO.iso / programming / oracle7 7.2 / DB / UTIL72 / DBMSSNAP.SQL < prev    next >
Encoding:
Text File  |  1995-05-09  |  11.2 KB  |  253 lines

  1. Rem 
  2. Rem $Header: dbmssnap.sql 7020200.1 95/02/15 18:31:07 cli Generic<base> $ 
  3. Rem  
  4. Rem  Copyright (c) 1991 by Oracle Corporation 
  5. Rem    NAME
  6. Rem      dbmssnap.sql - utilities for snapshots
  7. Rem    DESCRIPTION
  8. Rem      See below
  9. Rem    RETURNS
  10. Rem
  11. Rem  MODIFIED
  12. Rem     boki       12/21/94 -  merge changes from branch 1.6.710.10
  13. Rem     boki       12/08/94 -  add new formal parameter to refresh()
  14. Rem     adowning   11/11/94 -  merge changes from branch 1.6.710.9
  15. Rem     adowning   10/24/94 -  add comments to refresh
  16. Rem     adowning   10/11/94 -  make i_am_a_refresh a function
  17. Rem     rjenkins   02/17/94 -  adding defaults
  18. Rem     adowning   02/02/94 -  split file into public / private binary files
  19. Rem     rjenkins   01/13/94 -  adding rollback seg to refresh groups
  20. Rem     rjenkins   12/21/93 -  supporting import/export
  21. Rem     rjenkins   12/17/93 -  creating job queue
  22. Rem     rjenkins   11/02/93 -  adding explicit language flag to parse
  23. Rem     rjenkins   10/22/93 -  work even if name_tokenize does not work
  24. Rem     rjenkins   10/14/93 -  merge changes from branch k7010101
  25. Rem     rjenkins   10/12/93 -  moving comma_to_table to dbmsutil
  26. Rem     rjenkins   10/11/93 -  change default refresh method to NULL
  27. Rem     rjenkins   08/30/93 -  push deferred txn queues before refresh
  28. Rem     rjenkins   08/17/93 -  adding clear_refresh
  29. Rem     rjenkins   07/22/93 -  stop hardcoding foo, bar
  30. Rem     rjenkins   07/06/93 -  adding i_am_a_refresh
  31. Rem     ghallmar   05/02/93 -  add multi-table consistent refresh 
  32. Rem     mmoore     10/02/92 -  change pls_integer to binary_integer 
  33. Rem     rjenkins   06/02/92 -  changing comment types 
  34. Rem     rjenkins   02/12/92 -  more snapshot changes 
  35. Rem     rjenkins   11/25/91 -  Creation 
  36. -----------------------------------------------------------------------
  37.  
  38. Rem
  39. Rem  Headers
  40. Rem
  41.  
  42. CREATE OR REPLACE PACKAGE dbms_snapshot IS
  43.  
  44.   ------------
  45.   --  OVERVIEW
  46.   --
  47.   --  These routines allow the user to refresh snapshots and purge logs.
  48.  
  49.   ------------------------------------------------
  50.   --  SUMMARY OF SERVICES PROVIDED BY THIS PACKAGE
  51.   --
  52.   --  purge_log        - purge log of unnecessary rows
  53.   --  refresh        - refresh a given snapshot
  54.   --  refresh_all    - refresh all snapshots that are due
  55.   --                to be refreshed
  56.   --  drop_snapshot    - drop a given snapshot
  57.   --  set_up        - prepare master site to refresh a snapshot
  58.   --  wrap_up        - record a refresh at the master site
  59.   --  get_log_age    - find oldest date entry in log
  60.   --  testing        - test snapshots (currently null)
  61.   --  I_am_a_refresh    - flag used to let triggers identify refreshes
  62.  
  63.  
  64.   ----------------------------
  65.   --  PROCEDURES AND FUNCTIONS
  66.   --
  67.   PROCEDURE purge_log( master VARCHAR2, num BINARY_INTEGER DEFAULT 1, 
  68.                        flag VARCHAR2 DEFAULT 'NOP' );
  69.  
  70.   PROCEDURE refresh( list                 IN VARCHAR2,
  71.                      method               IN VARCHAR2 DEFAULT NULL,
  72.                      rollback_seg         IN VARCHAR2 DEFAULT NULL,
  73.                      push_deferred_rpc    IN BOOLEAN DEFAULT TRUE,
  74.                      refresh_after_errors IN BOOLEAN DEFAULT FALSE,
  75.              execute_as_user      IN BOOLEAN DEFAULT FALSE );
  76.  
  77.   --  -----------------------------------------------------------------------
  78.   --  Transaction consistent refresh of an array of snapshots
  79.   --
  80.   --  The snapshots are refreshed atomically and consistently. 
  81.   --  Atomically: all snapshots are refreshed or none are.
  82.   --  Consistently: all integrity constraints that hold among master tables 
  83.   --    will hold among the snapshot tables. 
  84.   --  The "method" string (not required) should contain a letter for each 
  85.   --    of the snapshots in the array according to the following codes:
  86.   --    '?' -- use fast refresh when possible
  87.   --    'F' -- use fast refresh or raise an error if not possible
  88.   --    'C' -- perform a complete refresh, copying the entire snapshot from
  89.   --           the master
  90.   --    The default method for refreshing a snapshot is the method stored for
  91.   --      that snapshot in the data dictionary.
  92.   --  The maximum number of snapshots that can be consistently refreshed is 100.
  93.   --   Rollback_seg is the name of the rollback segment to use while 
  94.   --     refreshing snapshots.
  95.   --   Push_deferred_rpc pushes changes from an updatable snapshot to its 
  96.   --     associated master before refreshing the snapshot.  Otherwise, these
  97.   --     changes may appear to be temporarily lost.
  98.   --   Refresh_after_errors, if TRUE, will allow the refresh to proceed
  99.   --     even if there are outstanding conflicts logged in the DefError
  100.   --     table for the snapshot's master.
  101.   --   Execute_as_user
  102.   --      IF TRUE the execution of deferred RPCs is authenticated at the 
  103.   --      remote system using the authentication context of the session user.  If 
  104.   --      FALSE the execution of deferred RPCs is authenticated at the remote system 
  105.   --      using the authentication contexts of the users that originally queued the 
  106.   --      deferred RPCs (indicated in the origin_user column of the deftran table). 
  107.   -- 
  108.   PROCEDURE refresh( tab                  IN OUT dbms_utility.uncl_array,
  109.                      method               IN VARCHAR2 DEFAULT NULL,
  110.                      rollback_seg         IN VARCHAR2 DEFAULT NULL,
  111.                      push_deferred_rpc    IN BOOLEAN DEFAULT TRUE,
  112.                      refresh_after_errors IN BOOLEAN DEFAULT FALSE,
  113.              execute_as_user      IN BOOLEAN DEFAULT FALSE );
  114.   --  External
  115.  
  116.   PROCEDURE refresh_all;
  117.   --  External, refresh all snapshots due to be refreshed
  118.   --  Requires ALTER ANY SNAPSHOT privilege
  119.  
  120.   PROCEDURE set_i_am_a_refresh(value IN  BOOLEAN);
  121.   --  External
  122.  
  123.   FUNCTION i_am_a_refresh RETURN BOOLEAN;
  124.   --  External
  125.  
  126.   PROCEDURE drop_snapshot( mowner VARCHAR2, master VARCHAR2, snapshot date);
  127.   --  Internal
  128.  
  129.   PROCEDURE set_up( mowner VARCHAR2, master VARCHAR2, log IN OUT VARCHAR2,
  130.                 snapshot IN OUT date, snaptime IN OUT date);
  131.   --  Internal
  132.  
  133.   PROCEDURE wrap_up( mowner VARCHAR2, master VARCHAR2, 
  134.                      sshot date, stime date);
  135.   --  Internal
  136.  
  137.   PROCEDURE get_log_age( oldest IN OUT date, mow VARCHAR2, mas VARCHAR2);
  138.   --  Internal
  139.  
  140.   PROCEDURE testing;
  141.  
  142. END dbms_snapshot;
  143. /
  144.  
  145. grant execute on dbms_snapshot to public
  146. /
  147. drop public synonym dbms_snapshot
  148. /
  149. create public synonym dbms_snapshot for dbms_snapshot
  150. /
  151.  
  152. CREATE OR REPLACE PACKAGE dbms_refresh IS
  153.   -- dbms_refresh is the interface for administering refresh groups.
  154.  
  155.   -- PARAMETERS:
  156.   -- NAME is of the form 'foo' or 'user.foo' or '"USER"."FOO"'.  
  157.   --   The logged-in user is used as a default.
  158.   -- LIST is a comma-separated list of objects to be refreshed, such as
  159.   --     'foo, scott.bar ,"SCOTT"."BLUE"'.  The default user is the owner
  160.   --     of the refresh group.
  161.   -- TAB  is a PL/SQL table of objects to be refreshed, starting with 1
  162.   --   and filling every number until an entry is NULL, with every entry
  163.   --   formatted the same way as NAME.  The default user is the owner
  164.   --   of the refresh group.
  165.   -- NEXT_DATE is the date for the refresh group to first be refreshed.
  166.   --   See dbmsjobq.sql .  If there is no current job, the default interval
  167.   --   will be 'null' and the job will delete itself after refreshing the
  168.   --   group at NEXT_DATE.
  169.   -- INTERVAL is used to determine the next NEXT_DATE.  See dbmsjobq.sql .
  170.   --   If there is no current job, NEXT_DATE will default to null and the
  171.   --   job will not run until you manually set NEXT_DATE to something else
  172.   --   or manually refresh the group.
  173.   -- IMPLICIT_DESTROY means to delete the refresh group when the last item
  174.   --   is subtracted from it.  The value is stored with the group definition.
  175.   --   Empty groups can be created with IMPLICIT_DESTROY set.
  176.  
  177.   aaspriv   BINARY_INTEGER;
  178.   -- Privilege number for ALTER ANY SNAPSHOT
  179.  
  180.   PROCEDURE make    ( name      IN VARCHAR2,
  181.                       list      IN VARCHAR2,
  182.                       next_date IN DATE,
  183.                       interval  IN VARCHAR2,
  184.                       implicit_destroy    IN BOOLEAN DEFAULT FALSE,
  185.                       lax       IN BOOLEAN DEFAULT FALSE,
  186.                       job       IN BINARY_INTEGER DEFAULT 0,
  187.                       rollback_seg  IN VARCHAR2 DEFAULT NULL,
  188.                       push_deferred_rpc    IN BOOLEAN DEFAULT TRUE,
  189.                       refresh_after_errors IN BOOLEAN DEFAULT FALSE );
  190.   PROCEDURE make    ( name      IN VARCHAR2,
  191.                       tab       IN dbms_utility.uncl_array,
  192.                       next_date IN DATE,
  193.                       interval  IN VARCHAR2,
  194.                       implicit_destroy    IN BOOLEAN DEFAULT FALSE,
  195.                       lax       IN BOOLEAN DEFAULT FALSE,
  196.                       job       IN BINARY_INTEGER DEFAULT 0,
  197.                       rollback_seg  IN VARCHAR2 DEFAULT NULL,
  198.                       push_deferred_rpc    IN BOOLEAN DEFAULT TRUE,
  199.                       refresh_after_errors IN BOOLEAN DEFAULT FALSE );
  200.   -- MAKE a new refresh group.
  201.  
  202.   PROCEDURE add     ( name      IN VARCHAR2,
  203.                       list      IN VARCHAR2,
  204.                       lax       IN BOOLEAN  DEFAULT FALSE );
  205.   PROCEDURE add     ( name      IN VARCHAR2,
  206.                       tab       IN dbms_utility.uncl_array,
  207.                       lax       IN BOOLEAN  DEFAULT FALSE );
  208.   -- ADD some refreshable objects to a refresh group.
  209.  
  210.   PROCEDURE subtract( name      IN VARCHAR2,
  211.                       list      IN VARCHAR2,
  212.                       lax       IN BOOLEAN  DEFAULT FALSE );
  213.   PROCEDURE subtract( name      IN VARCHAR2,
  214.                       tab       IN dbms_utility.uncl_array,
  215.                       lax       IN BOOLEAN  DEFAULT FALSE );
  216.   -- SUBTRACT some refreshable objects from a refresh group.
  217.  
  218.   PROCEDURE destroy ( name      IN VARCHAR2 );
  219.   -- DESTROY a refresh group, make it cease to exist.
  220.  
  221.   PROCEDURE change( name                 IN VARCHAR2,
  222.                     next_date            IN DATE DEFAULT NULL,
  223.                     interval             IN VARCHAR2 DEFAULT NULL,
  224.                     implicit_destroy     IN BOOLEAN  DEFAULT NULL,
  225.                     rollback_seg         IN VARCHAR2 DEFAULT NULL,
  226.                     push_deferred_rpc    IN BOOLEAN DEFAULT NULL,
  227.                     refresh_after_errors IN BOOLEAN DEFAULT NULL);
  228.   -- Change any changeable pieces of the job that does the refresh
  229.  
  230.   PROCEDURE refresh ( name      IN VARCHAR2 );
  231.   -- Atomically, consistently refresh all objects in a refresh group now.
  232.   -- Clear the BROKEN flag for the job if the refresh succeeds
  233.  
  234.   PROCEDURE user_export( rg#  IN BINARY_INTEGER,
  235.                          mycall IN OUT VARCHAR2);
  236.   -- Produce the text of a call for recreating the given group
  237.  
  238.   PROCEDURE user_export_child( myowner IN     VARCHAR2,
  239.                                myname  IN     VARCHAR2,
  240.                                mytype  IN     VARCHAR2,
  241.                                mycall  IN OUT VARCHAR2);
  242.   -- Produce the text of a call for recreating the given group item
  243. END dbms_refresh;
  244. /
  245.  
  246. GRANT EXECUTE ON dbms_refresh TO PUBLIC
  247. /
  248. DROP PUBLIC SYNONYM dbms_refresh
  249. /
  250. CREATE PUBLIC SYNONYM dbms_refresh FOR dbms_refresh
  251. /
  252.  
  253.